package com.wk.springboot;

import com.wk.springboot.config.MyBean;
import com.wk.springboot.config.MyConfiguration;
import org.springframework.beans.BeansException;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

@SpringBootApplication
public class PoiApplication implements ApplicationRunner, ApplicationContextAware {

    private ApplicationContext applicationContext;

    public static void main(String[] args) {
        SpringApplication.run(PoiApplication.class,args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        MyConfiguration bean = applicationContext.getBean(MyConfiguration.class);
        MyBean bean2 = applicationContext.getBean(MyBean.class);
        System.out.println("==========="+bean);
        System.out.println("==========="+bean2);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}



